package com.phb.puhuibao.web.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.idp.pub.service.IBaseService;
import com.idp.pub.web.controller.BaseController;
import com.phb.puhuibao.entity.ParTimeJob;

@Controller
@RequestMapping(value = "/parTimeJob")
public class ParTimeJobController extends BaseController<ParTimeJob, String> {
	@Resource(name = "parTimeJobService")
	public void setBaseService(IBaseService<ParTimeJob, String> baseService) {
		super.setBaseService(baseService);
	}
	@Resource(name = "jdbcTemplate")
	private JdbcTemplate jdbcTemplate;
    /**
     * 获得所有兼职类型()
     * @return
     */
	@RequestMapping(value="getParTimeJob")
	@ResponseBody
	public Map<String, Object> getParTimeJob() {
		Map<String, Object> data = new HashMap<String, Object>();
		Map<String,Object> retobj = null;
		List <Map<String, Object>> list = null;
		String sql="SELECT a.parttime_job_id,a.job_classtype FROM phb_part_time_job a";
		try {
			list = this.jdbcTemplate.queryForList(sql);
			if (!list.isEmpty()) {
				data.put("result", list);
				data.put("message", "查询成功");
				data.put("status", 1);
			}else {
				data.put("message", "数据为空");
				data.put("status", 2);
			}
		} catch (DataAccessException e) {
			data.put("message", "网络异常");
			data.put("status", 0);
		}
		return data;
	}
	  /**
     * 获得所有兼职类型
     * @return
     */
	@RequestMapping(value="getParTimeJobtype")
	@ResponseBody
	public Map<String, Object> getParTimeJobtype() {
		Map<String, Object> data = new HashMap<String, Object>();
		Map<String, Object> params = new HashMap<String, Object>();
		List<ParTimeJob> list = this.getBaseService().findList(params);
		try {
			data.put("result", list);
			data.put("message", "查询成功");
			data.put("status", 0);
		} catch (DataAccessException e) {
			data.put("message", "网络异常");
			data.put("status", 0);
		}
		return data;
	}
	
	
}
